@@ -1,12 +1,20 @@ |
||
| 1 | 1 |
require 'sinatra' |
| 2 | 2 |
require 'whois' |
| 3 |
+require 'haml' |
|
| 4 |
+require 'json' |
|
| 3 | 5 |
|
| 4 | 6 |
get '/' do |
| 5 |
- "Go to whois.com/jasonormand.com" |
|
| 7 |
+ haml :index |
|
| 6 | 8 |
end |
| 7 | 9 |
|
| 8 |
-get '/whois/:url' do |
|
| 9 |
- c = Whois::Client.new |
|
| 10 |
- r = c.query(params[:url]) |
|
| 11 |
- "#{r}"
|
|
| 10 |
+get '/lookup' do |
|
| 11 |
+ @lookup_url = params[:url] |
|
| 12 |
+ @lookup_info = Whois.query(params[:url]).to_s.gsub(/\n/, '<br>') |
|
| 13 |
+ haml :lookup |
|
| 14 |
+end |
|
| 15 |
+ |
|
| 16 |
+get '/lookup.json' do |
|
| 17 |
+ @lookup_info = Whois.query(params[:url]) |
|
| 18 |
+ content_type :json |
|
| 19 |
+ @lookup_info.to_json |
|
| 12 | 20 |
end |
@@ -0,0 +1,10 @@ |
||
| 1 |
+!!! |
|
| 2 |
+%html |
|
| 3 |
+ %head |
|
| 4 |
+ %title A free whois API service |
|
| 5 |
+ %body |
|
| 6 |
+ %p "Go to whois.com/jasonormand.com" |
|
| 7 |
+ |
|
| 8 |
+ %form{ :action => "/lookup", :method => "get"}
|
|
| 9 |
+ %input{ :type => "text", :name => "url"}
|
|
| 10 |
+ %input{ :type => "submit", :value => "Lookup Whois"}
|
@@ -0,0 +1,10 @@ |
||
| 1 |
+!!! |
|
| 2 |
+%html |
|
| 3 |
+ %head |
|
| 4 |
+ %title A free whois API service |
|
| 5 |
+ %body |
|
| 6 |
+ %div{:style => "border: solid 5px black; padding: 15px; margin-bottom: 15px;"}
|
|
| 7 |
+ = @lookup_url |
|
| 8 |
+ %div{:style => "border: solid 5px black; padding: 15px;"}
|
|
| 9 |
+ = @lookup_info |
|
| 10 |
+ |